/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Display

import com.vaadin.ui.*
import com.vaadin.ui.Button.*
import com.vaadin.data.util.*
import com.vaadin.event.*
import com.vaadin.event.Action.Handler
import com.vaadin.ui.Field.*
import com.vaadin.data.Property.*

/**
 *
 * @author patrick
 */
class CustomSlider extends com.vaadin.ui.Panel implements Handler{

    Slider field

    public CustomSlider(String string, int start, int end) {

        HorizontalLayout layout = new HorizontalLayout()
        layout.setMargin(false)
        layout.setSpacing(false)
        setContent(layout)
        addStyleName("light")

        field = new Slider(start, end)
        field.setWidth("175px")
 //       setCaption(string)

        addComponent(field)
        addActionHandler(this)
    }

    // Action list
    Action action_ok = new ShortcutAction("Default key",
        ShortcutAction.KeyCode.ENTER, null);
    Action action_clear = new ShortcutAction("Clear key",
        ShortcutAction.KeyCode.ESCAPE, null);


    def actions = [action_ok, action_clear]


    public Action[] getActions(Object target, Object sender) {
        return actions
    }


    public void handleAction(Action action, Object sender,
        Object target) {
        if (action == action_ok) {
            System.out.println(sender)
        } else if (action == action_clear) {
            System.out.println(sender)
        }
    }
}

